<template>
  <div class="brands-list">
    <div class="brand-list">
      <div class="brand2_1" v-for="brand in this.brandList" :key="brand.brandId">
<!--        <router-link to="/brand/brandDetail">-->
          <div class="pinpai">
            <a :href="brand.brandWeb">
              <img :src="brand.brandLogo" width="138" height="58"/>
            </a>
          </div>
<!--        </router-link>-->
        <div class="pinpai-content">
          <div class="pinpai1">
            <div class="gongsi"><a href="#"></a></div>
            <div class="branddes">
              <div class="branddes-title" v-text="brand.brandName"></div>
              <div class="branddes-content" v-text="brand.brandDesc"></div>
            </div>
          </div>
          <div class="brandimg">
            <a>
              <img :src="brand.brandImg" width="229" height="294"/>
            </a>
          </div>
        </div>
      </div>
    </div>
    <!--分页-->
    <div class="pagination">
      <el-pagination
        @size-change="sizeChangeHandle"
        @current-change="currentChangeHandle"
        :current-page="params.page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="params.limit"
        :total="this.totalCount"
        layout="total, sizes, prev, pager, next, jumper"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import { getBrands } from '../../api'
export default {
  name: 'BrandDetail',
  data () {
    return {
      brandList: [{
        brandId: 1,
        brandName: '',
        brandDesc: '',
        brandImg: '',
        brandLogo: '',
        brandWeb: ''
      }],
      params: {
        page: 1, // 当前页
        limit: 10 // 一页获取几条数据
      },
      totalCount: 100, // 数据库中一共有多少条数据
      totalPage: 10 // 数据库中按照limit的限制可以分为多少页
    }
  },
  methods: {
    // 获取到品牌数据列表
    getBrandList () {
      getBrands(this.params).then(({ data }) => {
        this.brandList = data.page.list
        this.totalCount = data.page.totalCount
        this.totalPage = data.page.totalPage
      }).catch((res) => {
        console.log(res)
      })
    },
    // 每页数
    sizeChangeHandle (val) {
      this.params.limit = val;
      this.params.page = 1;
      this.getBrandList();
    },
    // 当前页
    currentChangeHandle (val) {
      this.params.page = val;
      this.getBrandList();
    }
  },
  created () {
    this.getBrandList()
  }
}
</script>

<style scoped lang="less">
.brands-list {
  width: 980px;
  margin: 0 auto;
  text-align: left;

  .brand-list {
    .brand2_1 {
      width: 980px;
      height: 351px;
      box-sizing: border-box;
      overflow: hidden;
      border: 2px solid #e7e7e7;
      margin-top: 20px;
      background: #fff;
      padding: 18px;

      .pinpai-content {
        display: flex;
        justify-content: space-between;

        .pinpai1 {
          width: 640px;
          height: 240px;
          transform: translateX(20px);
          overflow: hidden;

          .branddes {
            .branddes-title {
              color: #00a2ea;
              font-size: 18px;
              padding-bottom: 10px;
            }
            .branddes-content{
              font-size: 14px;
              color: rgb(52, 52, 52);
              padding: 10px 0;
              line-height: 30px;
            }
          }
        }

        .brandimg {
          float: right;
          transform: translateY(-50px);
        }
      }

    }
  }

  // 分页
  .pagination {
    width: 980px;
    height: 50px;
    margin-top: 50px;
  }

}
</style>
